package com.geeguo.ebuilder.client.business.system.organization.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.geeguo.ebuilder.client.business.system.organization.model.OrganizationEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrganizationMapper extends BaseMapper<OrganizationEntity> {

    List<OrganizationEntity> list(@Param("tenantCode") String tenantCode);
    List<OrganizationEntity> listAllValid(@Param("tenantCode") String tenantCode);
    List<OrganizationEntity> listChildren(@Param("code") String code, @Param("tenantCode") String tenantCode);

    List<String> listChildrenIds(@Param("code") String code, @Param("tenantCode") String tenantCode);

    OrganizationEntity getByName(@Param("parentId") String parentId, @Param("name") String name, @Param("tenantCode") String tenantCode);

    String getMaxCode(@Param("code") String code, @Param("depth") Integer depth, @Param("tenantCode") String tenantCode);
    Integer getMaxSequence(@Param("parentId") String parentId, @Param("tenantCode") String tenantCode);
    Integer getChildCount(@Param("id") String id, @Param("tenantCode") String tenantCode);

    Integer updateByParams(@Param("params") Map<String, Object> changeValues);

    Integer updateCode(@Param("id") String id,
                       @Param("code") String code,
                       @Param("depth") Integer depth,
                       @Param("modifyTime") Date modifyTime,
                       @Param("modifyUser") String modifyUser);

    Integer isUsed(String id);
}